<%@ page import="java.util.ArrayList" %>
<%@ page import="db.DB" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="model.*" %>
<%@ page language="java" pageEncoding="utf-8" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet"/>
    <link rel="stylesheet" href="css/Site.css"/>
    <link rel="stylesheet" href="css/zy.all.css"/>
    <link rel="stylesheet" href="css/font-awesome.min.css"/>
    <link rel="stylesheet" href="css/amazeui.min.css"/>
    <link rel="stylesheet" href="css/admin.css"/>
</head>

<body>
<div class="dvcontent">

    <div>
        <!--tab start-->
        <div class="tabs" style="margin: 30px;">
            <div class="hd">
                <ul>
                    <li class="on" style="box-sizing: initial;-webkit-box-sizing: initial;">创建销售订单</li>
                    <li class="" id="showlist" style="box-sizing: initial;-webkit-box-sizing: initial;">查询销售订单</li>
                    <li class="" id="state" style="box-sizing: initial;-webkit-box-sizing: initial;">收入销售金额</li>
                </ul>
            </div>
            <div class="bd">
                <ul id="creatlist" style="display: block;padding: 20px;">
                    <div class="am-cf admin-main" style="padding-top: 0px;">
                        <!-- content start -->

                        <div class="am-cf admin-main" style="padding-top: 0px;">
                            <!-- content start -->
                            <div class="admin-content" id="createplist">
                                <div class="admin-content-body">

                                    <div class="am-g">
                                        <div class="am-u-sm-12 am-u-md-4 am-u-md-push-8">

                                        </div>
                                        <div class="am-u-sm-12 am-u-md-8 am-u-md-pull-4" style="padding-top: 30px;">
                                            <form class="am-form am-form-horizontal" action="" onsubmit="return addlist(document.getElementById('addlist_name'),
                                            document.getElementById('addlist_state'),document.getElementById('addlist_remark'));"
                                                  method="post">

                                                <div class="am-form-group">
                                                    <label class="am-u-sm-3 am-form-label">
                                                        客户</label>
                                                    <div class="am-u-sm-9">
                                                        <select name="addlist_name" id="addlist_name" required>
                                                            <option value="">请选择销售客户</option>
                                                            <%
                                                                DB db=new DB();
                                                                ArrayList sl = db.findcustomerInfo();
                                                                Iterator iter2 = sl.iterator();
                                                                while (iter2.hasNext()) {
                                                                    customer cu = (customer) iter2.next();
                                                            %>
                                                            <option value="<%= cu.getCustomer_id() %>"><%= cu.getCustomer_name() %></option>
                                                            <%
                                                                }
                                                            %>
                                                        </select> <small>销售订单客户</small>
                                                    </div>
                                                </div>
                                                <div class="am-form-group">
                                                    <label class="am-u-sm-3 am-form-label">
                                                        是否入账</label>
                                                    <div class="am-u-sm-9">
                                                        <select name="addlist_state" id="addlist_state" required>
                                                            <option value="">请选择该订单是否已入账</option>
                                                            <option value="1">是</option>
                                                            <option value="0">否</option>
                                                        </select> <small>订单是否入账</small>
                                                    </div>
                                                </div>

                                                <div class="am-form-group">
                                                    <label for="addlist_remark" class="am-u-sm-3 am-form-label">
                                                        备注</label>
                                                    <div class="am-u-sm-9">
                                                        <textarea class="" rows="5" id="addlist_remark" name="addlist_remark"
                                                                  placeholder="输入备注"></textarea>
                                                        <small>20字以内...</small>
                                                    </div>
                                                </div>
                                                <div class="am-form-group">
                                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                                        <input type="submit" class="am-btn am-btn-success"
                                                               value="创建订单"/>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                                <footer class="admin-content-footer">
                                    <hr>
                                    <p class="am-padding-left"></p>
                                </footer>
                            </div>
                            <!-- content end -->
                            <div id="createplistdetai" style="display: none">
                                <input type="text" id="showlistdetail" name="showlistdetail" value="1" style="display: none">
                                <%
                                    sale_list pl1=db.getnewslist();
                                    if(pl1==null){

                                        pl1.setSale_List_id(0);
                                        pl1.setCustomer_id(1);
                                        pl1.setstate((byte) 1);
                                    }
                                %>
                                <p><%=pl1.showdetail1()%><input type="submit" class="am-btn am-btn-success" style="float: right;" value="完成创建" onclick="gocreate()"/></p>
                                <p><%=pl1.showdetail2()%></p>

                                <input type="button" onclick="btn_slgoodadd(<%=pl1.getSale_List_id()%>,1)" value="添加销售商品"
                                       style="background-color: #2C7659;border-color: #2C7659"/>
                                <table class="table" id="supplyRecord">
                                    <thead>
                                    <tr>
                                        <th>商品编号</th>
                                        <th>商品名称</th>
                                        <th>销售数量</th>
                                        <th>编辑</th>
                                        <th>删除</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <%
                                        ArrayList pgl = db.findsgoodlistInfo(pl1.getSale_List_id());
                                        Iterator iter3 = pgl.iterator();
                                        while (iter3.hasNext()) {
                                            sale_list_good pg = (sale_list_good) iter3.next();
                                    %>
                                    <tr>
                                        <td><%=pg.getGoods_id()%></td>
                                        <td><%=pg.showgoodname()%></td>
                                        <td><%=pg.getSale_quantity()%></td>
                                        <td class="edit">
                                            <button onclick="btn_editslistgood(<%=pg.getSale_List_id()%>,<%=pg.getGoods_id()%>,1)"><i class="icon-edit bigger-120"></i>编辑
                                            </button>
                                        </td>
                                        <td class="delete">
                                            <button onclick="btn_deleteslistgood(<%=pg.getSale_List_id()%>,<%=pg.getGoods_id()%>,1)"><i class="icon-trash bigger-120"></i>退货
                                            </button>
                                        </td>
                                    </tr>
                                    <%
                                        }
                                    %>
                                    </tbody>

                                </table>
                            </div>
                        </div>
                        <!--添加 end-->
                    </div>

                </ul>
                <ul class="theme-popbod dform" style="display: none;">
                    <li>
                        <!--分页显示角色信息 start-->
                        <div id="showplist">
                            <table class="table" id="tbRecord">
                                <thead>
                                <tr>
                                    <th>销售订单号</th>
                                    <th>客户</th>
                                    <th>总金额</th>
                                    <th>是否入账</th>
                                    <th>备注</th>
                                    <th>详细</th>
                                    <th>删除</th>
                                </tr>
                                </thead>
                                <tbody>
                                <%
                                    ArrayList pll = db.findslistInfo();
                                    Iterator iter1 = pll.iterator();
                                    while (iter1.hasNext()) {
                                        sale_list pl = (sale_list) iter1.next();
                                %>
                                <tr>
                                    <td><%= pl.getSale_List_id() %></td>
                                    <td><%= pl.getcustomer_show() %></td>
                                    <td><%= pl.getSale_List_amount() %></td>
                                    <td><%= pl.getstate_show() %></td>
                                    <td><%= pl.getRemarks() %></td>
                                    <td class="edit"><button onclick="btn_showdetail(<%= pl.getSale_List_id() %>)"><i class="icon-edit bigger-120"></i>详细</button></td>
                                    <td class="delete"><button onclick="btn_listdelete(<%= pl.getSale_List_id() %>)"><i class="icon-trash bigger-120"></i>删除</button></td>
                                </tr>
                                <%
                                    }
                                %>

                                </tbody>

                            </table>
                        </div>
                        <!--分页显示角色信息 end-->
                        <div id="showplistdetai" style="display: none">
                            <input type="text" id="showlistdetail" name="showlistdetail" value="1" style="display: none">
                            <%
                                sale_list pl2=new sale_list();
                                if(session.getAttribute("slistinfo")==null){

                                    pl2.setSale_List_id(0);
                                    pl2.setCustomer_id(1);
                                    pl2.setstate((byte) 1);
                                }
                                else{pl2 = (sale_list) session.getAttribute("slistinfo");}
                            %>
                            <p><%=pl2.showdetail1()%><input type="submit" class="am-btn am-btn-success" style="float: right;" value="返回" onclick="golist()"/></p>
                            <p><%=pl2.showdetail2()%></p>

                            <input type="button" onclick="btn_slgoodadd(<%=pl2.getSale_List_id()%>,2)" value="添加销售商品"
                                   style="background-color: #2C7659;border-color: #2C7659"/>
                            <table class="table" id="supplyRecord">
                                <thead>
                                <tr>
                                    <th>商品编号</th>
                                    <th>商品名称</th>
                                    <th>销售数量</th>
                                    <th>编辑</th>
                                    <th>删除</th>
                                </tr>
                                </thead>
                                <tbody>
                                <%
                                    ArrayList pgl1 = db.findsgoodlistInfo(pl2.getSale_List_id());
                                    Iterator iter6 = pgl1.iterator();
                                    while (iter6.hasNext()) {
                                        sale_list_good pg = (sale_list_good) iter6.next();
                                %>
                                <tr>
                                    <td><%=pg.getGoods_id()%></td>
                                    <td><%=pg.showgoodname()%></td>
                                    <td><%=pg.getSale_quantity()%></td>
                                    <td class="edit">
                                        <button onclick="btn_editslistgood(<%=pg.getSale_List_id()%>,<%=pg.getGoods_id()%>,2)"><i class="icon-edit bigger-120"></i>编辑
                                        </button>
                                    </td>
                                    <td class="delete">
                                        <button onclick="btn_deleteslistgood(<%=pg.getSale_List_id()%>,<%=pg.getGoods_id()%>,2)"><i class="icon-trash bigger-120"></i>退货
                                        </button>
                                    </td>
                                </tr>
                                <%
                                    }
                                %>
                                </tbody>

                            </table>
                        </div>
                    </li>
                    <!--添加 end-->
                    <!--end-->
                </ul>
                <ul class="theme-popbod dform" style="display: none;">
                    <li>
                        <!--分页显示角色信息 start-->
                        <div id="showunplist">
                            <table class="table" >
                                <thead>
                                <tr>
                                    <th>销售订单号</th>
                                    <th>客户</th>
                                    <th>总金额</th>
                                    <th>是否入账</th>
                                    <th>备注</th>
                                    <th>确认入账</th>
                                </tr>
                                </thead>
                                <tbody>
                                <%
                                    ArrayList pll2 = db.findunslistInfo();
                                    Iterator iter7 = pll2.iterator();
                                    while (iter7.hasNext()) {
                                        sale_list pl = (sale_list) iter7.next();
                                %>
                                <tr>
                                    <td><%= pl.getSale_List_id() %></td>
                                    <td><%= pl.getcustomer_show() %></td>
                                    <td><%= pl.getSale_List_amount() %></td>
                                    <td><%= pl.getstate_show() %></td>
                                    <td><%= pl.getRemarks() %></td>
                                    <td class="edit"><button onclick="btn_state(<%= pl.getSale_List_id() %>)"><i class="icon-edit bigger-120"></i>结账</button></td>
                                </tr>
                                <%
                                    }
                                %>

                                </tbody>

                            </table>
                        </div>
                        <!--分页显示角色信息 end-->

                    </li>
                    <!--添加 end-->
                    <!--end-->
                </ul>


            </div>
        </div>
        <!--tab end-->

    </div>


    <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="js/plugs/Jqueryplugs.js" type="text/javascript"></script>
    <script src="js/_layout.js"></script>
    <script src="js/plugs/jquery.SuperSlide.source.js"></script>
    <script>
        window.onload = function () {
            <%
            String salepage=(String)session.getAttribute("salepage");  //接收后台传来的datapage
            if(salepage=="showlist2"){  //判断datapage
            %>
            document.getElementById("showlist").click();//弹出对应内容
            document.getElementById("showplist").style.display='none';
            document.getElementById("showplistdetai").style.display='block';
            <%
            }
            else if(salepage=="showlist1"){  //判断datapage
            %>
            document.getElementById("showlist").click();//弹出对应内容
            <%
            }
            else if(salepage=="createlist2"){  //判断datapage
            %>
            document.getElementById("createplist").style.display='none';
            document.getElementById("createplistdetai").style.display='block';
            <%
            }
            else if(salepage=="state"){  //判断datapage
            %>
            document.getElementById("state").click();//弹出对应内容
            <%
            }
            session.setAttribute("salepage","");  //将salepage值设为空，否则将一直弹出。
            String mess=(String)session.getAttribute("message");  //接收后台传来的message
            if(mess!=null&&!mess.equals("")){  //判断message
                %>
                alert("<%=mess%>");  //弹出警示框
            <%
                    session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                }
            %>
        }
        var num = 1;
        $(function () {

            $(".tabs").slide({trigger: "click"});

        });

        function golist() {
            document.getElementById("showplist").style.display='block';
            document.getElementById("showplistdetai").style.display='none';
            return true;
        }

        function gocreate() {
            document.getElementById("createplist").style.display='block';
            document.getElementById("createplistdetai").style.display='none';
            return true;
        }

        function addlist(obj1,obj2,obj3) {
            var request = new XMLHttpRequest();
            let params = "customerid="+encodeURIComponent(obj1.value)
                +"&state="+encodeURIComponent(obj2.value)
                +"&remark="+encodeURIComponent(obj3.value);
            request.open("post", "/test_war/addslist", true);
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.send(params);
            var x = 0;
            request.onreadystatechange = function () {
                x=x+1;
                if(x==1){
                    location.reload();
                }
                <%
                mess=(String)session.getAttribute("message");  //接收后台传来的message
                if(mess!=null&&!mess.equals("")){  //判断message
                %>
                alert("<%=mess%>");  //弹出警示框
                <%
                        session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                    }
                %>
            }
            return true;
        }

        var btn_slgoodadd = function (id,page) {
            $.jq_Panel({
                url: "/RawMaterialsType/EditRawMaterialsType?id=" + id,
                message: "<div class=\"admin-content\">\n" +
                    "                                <div class=\"admin-content-body\">\n" +
                    "\n" +
                    "                                    <div class=\"am-g\">\n" +
                    "                                        <div class=\"am-u-sm-12 am-u-md-4 am-u-md-push-8\">\n" +
                    "\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"am-u-sm-12 am-u-md-8 am-u-md-pull-4\" style=\"padding-top: 30px;\">\n" +
                    "                                            <form class=\"am-form am-form-horizontal\" action=\"/test_war/addslistgood\"\n" +
                    "                                                  method=\"post\">\n" +
                    "                                                <input type=\"text\" id=\"addplistgood\" name=\"addplistgood\" value=\""+id+"\" style=\"display: none\">\n" +
                    "                                                <input type=\"text\" id=\"whichpage\" name=\"whichpage\" value=\""+page+"\" style=\"display: none\">\n" +
                    "\n" +
                    "                                                <div class=\"am-form-group\">\n" +
                    "                                                    <label class=\"am-u-sm-3 am-form-label\">\n" +
                    "                                                        商品名</label>\n" +
                    "                                                    <div class=\"am-u-sm-9\">\n" +
                    "                                                        <select id=\"addplistgoodname\" name=\"addplistgoodname\" required>\n" +
                    "                                                            <option value=\"\">请选择销售商品</option>\n"
                                                                                <%
                                                                                    ArrayList gl1 = db.findgoodInfo();
                                                                                    Iterator iter5 = gl1.iterator();
                                                                                    while (iter5.hasNext()) {
                                                                                        good gd = (good)iter5.next();
                                                                                %>
                                                                                +"<option value=\""+"<%= gd.getGoods_id() %>"+"\">"+"<%= gd.getGood_name() %>"+"</option>\n"
                                                                                <%
                                                                                    }
                                                                                %> +
                    "                                                        </select> <small>销售的商品名</small>\n" +
                    "                                                    </div>\n" +
                    "                                                </div>\n" +
                    "\n" +
                    "                                                <div class=\"am-form-group\">\n" +
                    "                                                    <label class=\"am-u-sm-3 am-form-label\">\n" +
                    "                                                        销售数量</label>\n" +
                    "                                                    <div class=\"am-u-sm-9\">\n" +
                    "                                                        <input type=\"text\" id=\"addplistgoodamount\" required\n" +
                    "                                                               placeholder=\"请输入销售数量\" name=\"addplistgoodamount\">\n" +
                    "                                                        <small>输入正整数</small>\n" +
                    "                                                    </div>\n" +
                    "                                                </div>\n" +
                    "\n" +
                    "                                                <div class=\"am-form-group\">\n" +
                    "                                                    <div class=\"am-u-sm-9 am-u-sm-push-3\">\n" +
                    "                                                        <input type=\"submit\" class=\"am-btn am-btn-success\"\n" +
                    "                                                               value=\"添加商品\"/>\n" +
                    "                                                    </div>\n" +
                    "                                                </div>\n" +
                    "                                            </form>\n" +
                    "                                        </div>\n" +
                    "                                    </div>\n" +
                    "                                </div>\n" +
                    "                                <footer class=\"admin-content-footer\">\n" +
                    "                                    <hr>\n" +
                    "                                    <p class=\"am-padding-left\"></p>\n" +
                    "                                </footer>\n" +
                    "                            </div>",
                title: "添加商品",
                dialogModal: true,
                iframeWidth: 500,
                iframeHeight: 600
            });
        }

        var btn_editslistgood = function (listid,goodid,page) {
            $.jq_Panel({
                url: "/RawMaterialsType/EditRawMaterialsType?id=",
                message: "<div class=\"admin-content\">\n" +
                    "                                <div class=\"admin-content-body\">\n" +
                    "\n" +
                    "                                    <div class=\"am-g\">\n" +
                    "                                        <div class=\"am-u-sm-12 am-u-md-4 am-u-md-push-8\">\n" +
                    "\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"am-u-sm-12 am-u-md-8 am-u-md-pull-4\" style=\"padding-top: 30px;\">\n" +
                    "                                            <form class=\"am-form am-form-horizontal\" action=\"/test_war/editslistgood\"\n" +
                    "                                                  method=\"post\">\n" +
                    "                                                <input type=\"text\" id=\"listid\" name=\"listid\" value=\""+listid+"\" style=\"display: none\">\n" +
                    "                                                <input type=\"text\" id=\"goodid\" name=\"goodid\" value=\""+goodid+"\" style=\"display: none\">\n" +
                    "\n" +
                    "                                                <input type=\"text\" id=\"whichpage\" name=\"whichpage\" value=\""+page+"\" style=\"display: none\">\n" +
                    "                                                <div class=\"am-form-group\">\n" +
                    "                                                    <label class=\"am-u-sm-3 am-form-label\">\n" +
                    "                                                        商品编号</label>\n" +
                    "                                                    <div class=\"am-u-sm-9\">\n" +
                    "                                                        <input type=\"text\" value=\""+goodid+"\" readonly=\"readonly\">\n" +
                    "                                                        <small>要修改的商品编号</small>\n" +
                    "                                                    </div>\n" +
                    "                                                </div>\n" +
                    "\n" +
                    "                                                <div class=\"am-form-group\">\n" +
                    "                                                    <label class=\"am-u-sm-3 am-form-label\">\n" +
                    "                                                        销售数量</label>\n" +
                    "                                                    <div class=\"am-u-sm-9\">\n" +
                    "                                                        <input type=\"text\" id=\"goodamount\" required\n" +
                    "                                                               placeholder=\"请输入修改的销售数量\" name=\"goodamount\">\n" +
                    "                                                        <small>输入正整数</small>\n" +
                    "                                                    </div>\n" +
                    "                                                </div>\n" +
                    "\n" +
                    "                                                <div class=\"am-form-group\">\n" +
                    "                                                    <div class=\"am-u-sm-9 am-u-sm-push-3\">\n" +
                    "                                                        <input type=\"submit\" class=\"am-btn am-btn-success\"\n" +
                    "                                                               value=\"确认修改\"/>\n" +
                    "                                                    </div>\n" +
                    "                                                </div>\n" +
                    "                                            </form>\n" +
                    "                                        </div>\n" +
                    "                                    </div>\n" +
                    "                                </div>\n" +
                    "                                <footer class=\"admin-content-footer\">\n" +
                    "                                    <hr>\n" +
                    "                                    <p class=\"am-padding-left\"></p>\n" +
                    "                                </footer>\n" +
                    "                            </div>",
                title: "添加商品",
                dialogModal: true,
                iframeWidth: 500,
                iframeHeight: 600
            });
        }

        var btn_deleteslistgood = function (listid,goodid,page) {
            $.jq_Confirm({
                message: "您确定要退货吗?",
                btnOkClick: function () {
                    var request = new XMLHttpRequest();
                    let params = "listid="+encodeURIComponent(listid)
                        +"&goodid="+encodeURIComponent(goodid)
                        +"&whichpage="+encodeURIComponent(page);
                    request.open("post", "/test_war/deleteslistgood", true);
                    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                    request.send(params);
                    window.history.go();
                    <%
                    mess=(String)session.getAttribute("message");  //接收后台传来的message
                    if(mess!=null&&!mess.equals("")){  //判断message
                    %>
                    alert("<%=mess%>");  //弹出警示框
                    <%
                            session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                        }
                    %>

                    request.onreadystatechange = function () {
                        x=x+1;
                        if(x==1){
                            window.history.go();
                        }
                        <%
                        mess=(String)session.getAttribute("message");  //接收后台传来的message
                        if(mess!=null&&!mess.equals("")){  //判断message
                        %>
                        alert("<%=mess%>");  //弹出警示框
                        <%
                                session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                            }
                        %>
                    }
                }
            });
        }

        var btn_listdelete = function (listid) {
            $.jq_Confirm({
                message: "您确定要退货吗?",
                btnOkClick: function () {
                    var request = new XMLHttpRequest();
                    let params = "listid="+encodeURIComponent(listid);
                    request.open("post", "/test_war/deleteslist", true);
                    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                    request.send(params);
                    window.history.go();
                    <%
                    mess=(String)session.getAttribute("message");  //接收后台传来的message
                    if(mess!=null&&!mess.equals("")){  //判断message
                    %>
                    alert("<%=mess%>");  //弹出警示框
                    <%
                            session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                        }
                    %>

                    request.onreadystatechange = function () {
                        x=x+1;
                        if(x==1){
                            window.history.go();
                        }
                        <%
                        mess=(String)session.getAttribute("message");  //接收后台传来的message
                        if(mess!=null&&!mess.equals("")){  //判断message
                        %>
                        alert("<%=mess%>");  //弹出警示框
                        <%
                                session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                            }
                        %>
                    }
                }
            });
        }

        function btn_showdetail(listid) {
            var request = new XMLHttpRequest();
            let params = "listid="+encodeURIComponent(listid);
            request.open("post", "/test_war/showslistdetail", true);
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.send(params);
            var x = 0;
            request.onreadystatechange = function () {
                x=x+1;
                if(x==1){
                    location.reload();
                    // window.history.go();
                    // document.getElementById("showplist").style.display='none';
                    // document.getElementById("showplistdetai").style.display='block';
                }
                <%
                mess=(String)session.getAttribute("message");  //接收后台传来的message
                if(mess!=null&&!mess.equals("")){  //判断message
                %>
                alert("<%=mess%>");  //弹出警示框
                <%
                        session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                    }
                %>
            }
            document.getElementById("showlist").click();
            return true;
        }

        var btn_state = function (listid) {
            $.jq_Confirm({
                message: "您确定已完成该订单的入账吗?",
                btnOkClick: function () {
                    var request = new XMLHttpRequest();
                    let params = "listid="+encodeURIComponent(listid);
                    request.open("post", "/test_war/sliststate", true);
                    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                    request.send(params);
                    window.history.go();
                    <%
                    mess=(String)session.getAttribute("message");  //接收后台传来的message
                    if(mess!=null&&!mess.equals("")){  //判断message
                    %>
                    alert("<%=mess%>");  //弹出警示框
                    <%
                            session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                        }
                    %>

                    request.onreadystatechange = function () {
                        x=x+1;
                        if(x==1){
                            window.history.go();
                        }
                        <%
                        mess=(String)session.getAttribute("message");  //接收后台传来的message
                        if(mess!=null&&!mess.equals("")){  //判断message
                        %>
                        alert("<%=mess%>");  //弹出警示框
                        <%
                                session.setAttribute("message","");  //将message值设为空，否则将一直弹出。
                            }
                        %>
                    }
                }
            });
        }


        var btn_save = function () {
            var pid = $("#RawMaterialsTypePageId  option:selected").val();
            var name = $("#RawMaterialsTypeName").val();
            var desc = $("#RawMaterialsTypeDescription").val();
            var ramark = $("#Ramark").val();
            $.ajax({
                type: "post",
                url: "/RawMaterialsType/AddRawMaterialsType",
                data: {name: name, pid: pid, desc: desc, ramark: ramark},
                success: function (data) {
                    if (data > 0) {
                        $.jq_Alert({
                            message: "添加成功",
                            btnOktext: "确认",
                            dialogModal: true,
                            btnOkClick: function () {
                                //$("#RawMaterialsTypeName").val("");
                                //$("#RawMaterialsTypeDescription").val("");
                                //$("#Ramark").val("");
                                //page1();
                                location.reload();

                            }
                        });
                    }
                }
            });
            alert(t);
        }

        var btn_edit = function (id) {
            $.jq_Panel({
                url: "/RawMaterialsType/EditRawMaterialsType?id=" + id,
                title: "编辑分类",
                dialogModal: true,
                iframeWidth: 500,
                iframeHeight: 400
            });
        }
        var btn_delete = function (id) {
            $.jq_Confirm({
                message: "您确定要删除吗?",
                btnOkClick: function () {

                }
            });
        }
    </script>

</div>
</body>

</html>